package cn.huyanbing.middleware.thread.research;

import java.util.concurrent.CompletableFuture;

/**
 * @BelongProject middleware
 * @BelongPackage cn.huyanbing.middleware.thread.research
 * @Description TODO
 * @ClassName CompletableFutureTest
 * @Author huyangbing
 * @Date 2024/11/11 20:11
 * @Version 1.0.0
 */
public class CompletableFutureTest {

    public static void main(String[] args) {


        CompletableFuture<String> f0=
                CompletableFuture.supplyAsync(()->"Hello Word")
                .thenApply(s->s+"QQ")
                .thenApply(String::toUpperCase);

        System.out.println(f0.join());



        CompletableFuture<Integer> f1=CompletableFuture.supplyAsync(()->(7/0)).
                thenApply(r->r*10).exceptionally(s->0);
        System.out.println(f1.join());



    }
}
